package com.jeeplus.modules.sys.web;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.modules.sys.entity.DaiBanTongJi;
import com.jeeplus.modules.sys.entity.Office;
import com.jeeplus.modules.sys.service.DaiBanTongJiService;
import com.jeeplus.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @author xujin
 * @title: DaiBanController
 * @projectName ESA
 * @description: TODO
 * @date 2019-12-0310:52
 */
@Controller
public class DaiBanController extends BaseController {
    @Autowired
    private DaiBanTongJiService daiBanTongJiService;

    @ResponseBody
    @RequestMapping(value = "${adminPath}/findDaiBan")
    public Map<String, Object> findDaiBan(@RequestParam(value = "company",defaultValue = "",required = false) String company,
            DaiBanTongJi daiBanTongJi, HttpServletRequest request, HttpServletResponse response, Model model){
        daiBanTongJi.setCompany(new Office(company));
        Page<DaiBanTongJi> page = daiBanTongJiService.findPage(new Page<DaiBanTongJi>(request, response), daiBanTongJi);
        return getBootstrapData(page);
    }

    @ResponseBody
    @RequestMapping(value = "${adminPath}/findDaiBanYj")
    public List<DaiBanTongJi> findDaiBanYj(@RequestParam(value = "company",defaultValue = "",required = false) String company){
        company	= UserUtils.getUser().getId();
        return daiBanTongJiService.findList1(company);
    }
}
